import { createRouter, createWebHistory } from 'vue-router'

// import CreateAddressView from "@/views/my/CreateAddressView.vue";


const router = createRouter({
  history: createWebHistory(),
  routes: [
    {
      path: '/',
      redirect:"/home",
      name: 'layout',
      component: () => import ("@/views/layout/LayoutView.vue"),
      children:[
        {
          path:"home",
          component:() =>import ("@/views/home/HomeView.vue"),
          children:[
            {
              path:"/nearBy",
              component:() =>import ("@/views/home/NearByView.vue"),

            }
          ]
        },
        {
          path:"/cart",
          component:()=> import ("@/views/cart/CartView.vue")
        },
        {
          path:"/order",
          component:() =>import ("@/views/order/OrderView.vue")
        },
        {
          path:"/my",
          component:() =>import ("@/views/my/MyView.vue")
        }
   
      ]
    },
    {
      path:"/login",
      component:()=>import ("@/views/login/LoginView.vue")
    },
    {
          name:"shop",
          path:"/shop/:id",
          component:() =>import( "@/views/shop/ShopView.vue"),
          props(router){
            // console.log(router);
            return router.params
          }
        },
        {
          name:"OrderConfirm",
          path:"/OrderConfirm",
          component:() =>import ( "@/views/orderConfirm/OrderConfirmationView.vue"),

        },
        {
          name:"address",
          path:"/address/:from",
          component:() =>import ("@/views/address/AddressView.vue"),
          // beforeEnter(to,form,next){
          //   console.log("to:",to);
          //   console.log("form:",form);
          //   next();
          // }
        },
        {
          name:"CreateAddress",
          path:"/CreateAddress/:from",
          component:() =>import ("@/views/address/CreateAddressView.vue")
        },
      {
        path:"/test",
        component:() =>import ("@/components/test.vue")
      }
    
    
  ]
})

export default router
